from openpyxl import load_workbook
from openpyxl import Workbook
import os
import random
import datetime
folder_path = 'd:/data/'
for root, dirs, files in os.walk(folder_path):
    for file1 in files:
        ####文件路径
        file_path = os.path.join(root, file1)
        print(file_path)
        if '.xlsx' in file_path:
            wb = load_workbook(file_path)
            ws=wb.active
            print("开始处理")
            max_row=ws.max_row*2
            TIME,TIMEE="","" 
            for row in range(10,max_row,6):
                if ws.cell(row,1).value is not None:
                    TIME=ws.cell(row,1).value
                    TIMEE=ws.cell(row,2).value+datetime.timedelta(hours=2)
                    print("ok")
                    ws.insert_rows(row+1)
                    ws.cell(row+1, 1).value = TIME
                    ws.cell(row+1, 2).value = TIMEE
                    ws.cell(row+1, 3).value = 6
                    print("okok")
                    for ii in range(4, 14):
                        ws.cell(row+1, ii).value = round(ws.cell(row, ii).value+random.uniform(0, 0.01),3)
                #row += 10
            wb.save(file_path)
            print("保存成功")



